#include "base/LoadRequest.h"
#include "util/Logger.h"

NEW_DELETE_OPERATORS_CPP(LoadRequest,100);

LoadRequest::LoadRequest (const LoadRequest& lr) :
    DataRequest(lr.getAddress(),
                lr.getProcessor(),
                lr.getSource(),
                lr.getDestination(),
                lr.getDataSize(),
                lr.getSize() - lr.getDataSize())
{
    memcpy(data, lr.getData(), lr.getDataSize());
}

const char* LoadRequest::toString () {
    char tmp[512];
    strcpy(tmp, Request::toString());
    sim_sprintf(string, "%s(LD)[%s][%08llx]%s", 
                tmp, 
                isExclusive() ? "EXCLUSIVE":"NON-EXCLUSIVE",
                getAddress(),
                isUncached() ? " (uncached)" : "");
    return string;
}

// NOTE: the following method is called when a request is resent after it got nacked with retry.
// make sure that all status newly added to the classes are properly reset in the method
void LoadRequest::resetForRetry () {
    DataRequest::resetForRetry();
    shared = false;
    aborted = false;
}

